<html lang="zh-CN" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8">
    <base th:href="${#request.getContextPath()}+'/'">
    <link href="static/default.css" rel="stylesheet" id="lhgdialoglink">

    <title>商品管理</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <!-- head start-->

    <link href="static/bootstrap.min.css" rel="stylesheet">
    <link rel="stylesheet" href="static/font-awesome.min.css">
    <link rel="stylesheet" href="static/font.css">
    <link rel="stylesheet" href="static/ace.min.css">
    <link rel="stylesheet" href="static/ace-rtl.min.css">
    <link rel="stylesheet" href="static/jquery-ui-1.10.3.custom.min.css">
    <link rel="stylesheet" href="static/jquery.gritter.css">
    <link type="text/css" rel="stylesheet" href="static/public.css">

    <script src="static/ace-extra.min.js"></script>

    <!-- 系统共用js文件 -->
    <link rel="stylesheet" type="text/css" href="static/ymPrompt.css">
    <script type="text/javascript" src="static/ymPrompt.js"></script>
    <script type="text/javascript" src="static/public.js"></script>
    <script type="text/javascript" src="static/publics.js"></script>
    <script type="text/javascript" src="static/table.js"></script>
    <script type="text/javascript" src="static/vdata.js"></script>

    <!-- head over-->
    <link href="static/WdatePicker.css" rel="stylesheet" type="text/css">
</head>

<body style="">

<!-- head start-->

<div class="navbar-container" id="navbar-container">
    <div class="navbar-header pull-left">
        <a href="http://localhost:8081/cust/index" class="navbar-brand">
            <small>
                <i class="icon-leaf"></i>
                微信公众号盈利平台-商户后台管理
            </small>
        </a><!-- /.brand -->
    </div><!-- /.navbar-header -->

</div><!-- /.container -->
<!-- head over-->
</div>

<div class="main-container" id="main-container">
    <script type="text/javascript">
        try {
            ace.settings.check('main-container', 'fixed')
        } catch (e) {
        }
    </script>

    <div class="main-container-inner">


        <div class="main-content">
            <div class="page-content">
                <div class="page-header">
                    <h1>
                        温馨提示：
                        <small>
                            商品添加成功后，需要管理员审核通过后才能发布到会员推广商品列表
                        </small>
                    </h1>
                </div>

                <form method="post" name="copy_form" id="copy_form" action="/good/saveGood"
                      enctype="multipart/form-data">
                    <div class="widget-main">
                        <input type="hidden" id="sku_str" name="sku_str" value="">
                        <input type="hidden" id="ctype" name="ctype" value="custGood">
                        <input type="hidden" id="sku_title" name="skuTitle" value="">
                        <input type="hidden" id="sku_cost" name="skuCost" value="">
                        <input type="hidden" id="sku_pmoney" name="skuPmoney" value="">
                        <input type="hidden" id="service_money" name="serviceMoney" value="">
                        <input type="hidden" id="sku_price" name="skuPrice" value="">
                        <input type="hidden" id="good_id" name="goodId" value="">
                        <input type="hidden" id="copy_id" name="copyId" value="">
                        <input type="hidden" id="spc_id" name="spcId" value="">
                        <input type="hidden" id="zon_id" name="zonId" value="">
                        <input type="hidden" id="optype" name="optype" value="add_good">
                        <input type="hidden" id="iswxpay" name="iswxpay" value="0">
                        <input type="hidden" id="customer_id" name="customer_id">

                        <table class="table table-bordered table-striped">
                            <tbody>
                            <tr>
                                <td align="right">
                                    <span class="red">*</span><strong>商品名称：</strong>
                                </td>
                                <td>
                                    <input type="text" id="goodName" name="goodName" value="">
                                </td>

                            </tr>

                            <tr>
                                <td align="right"><span class="red">*</span><strong>商品类型：</strong></td>
                                <td>
                                    <select name="typeId" id="type_id" style="width:252px;font-size:14px"
                                            class="selectBox">
                                        <option value="">请选择...</option>


                                        <option value="01">保健品</option>

                                        <option value="02">饰品</option>

                                        <option value="03">护肤品</option>

                                        <option value="04">床上用品</option>

                                        <option value="05">生活用品</option>

                                        <option value="06">减肥产品</option>

                                        <option value="07">113</option>

                                        <option value="08">23</option>


                                    </select>
                                </td>
                            </tr>
                            <tr>
                                <td align="right"><span class="red">*</span><strong>排序编号：</strong></td>
                                <td>
                                    <input type="text" id="order_no" name="orderNo" onkeyup="checkVal2(this);"
                                           value="">
                                </td>
                            </tr>
                            <tr>
                                <td align="right"><span class="red">*</span><strong>购买作弊值：</strong></td>
                                <td>
                                    <input type="text" id="sell_num" name="sellNum" onkeyup="checkVal2(this);"
                                           value="">
                                </td>
                            </tr>
                            <tr>
                                <td align="right"><strong>图片预览：</strong></td>
                                <td>
                                    <div id="sm_div">

                                        <img src="static/no_pic.png" id="sm_yl"
                                             style="height:150px;border:1px solid #ddd;">


                                    </div>
                                </td>
                            </tr>
                            <tr>
                                <td align="right"><span class="red">*</span><strong>上传图片：</strong></td>
                                <td>
                                    <input type="file" name="pic1" id="smfile&quot;"
                                           style="width:540px;height:22px;cursor:hand" class="fileinput"
                                           onchange="checkImgType(this);setPreview(this,&#39;sm_yl&#39;,&#39;sm_div&#39;,240,150);">
                                </td>
                            </tr>

                            <tr>
                                <td align="right"><strong>图片2预览：</strong></td>
                                <td>
                                    <div id="sm_div1">

                                        <img src="static/no_pic.png" id="sm_yl1"
                                             style="height:150px;border:1px solid #ddd;">


                                    </div>
                                </td>
                            </tr>
                            <tr>
                                <td align="right"><span class="red">*</span><strong>上传图片2：</strong></td>
                                <td>
                                    <input type="file" name="pic2" id="smfile1&quot;"
                                           style="width:540px;height:22px;cursor:hand" class="fileinput"
                                           onchange="checkImgType(this);setPreview(this,&#39;sm_yl1&#39;,&#39;sm_div1&#39;,240,150);">
                                </td>
                            </tr>

                            <tr>
                                <td align="right"><strong>图片3预览：</strong></td>
                                <td>
                                    <div id="sm_div2">

                                        <img src="static/no_pic.png" id="sm_yl2"
                                             style="height:150px;border:1px solid #ddd;">


                                    </div>
                                </td>
                            </tr>
                            <tr>
                                <td align="right"><span class="red">*</span><strong>上传图片3：</strong></td>
                                <td>
                                    <input type="file" name="pic3" id="smfile2&quot;"
                                           style="width:540px;height:22px;cursor:hand" class="fileinput"
                                           onchange="checkImgType(this);setPreview(this,&#39;sm_yl2&#39;,&#39;sm_div2&#39;,240,150);">
                                </td>
                            </tr>

                            <tr>
                                <td align="right"><span class="red">*</span><strong>推广说明：</strong></td>
                                <td>
                                    <textarea id="promoteDesc" name="promoteDesc"
                                              style="width:540px; height: 160px;"></textarea>
                                </td>
                            </tr>

                            <tr>
                                <td align="right"><span class="red">*</span><strong>商品套餐：</strong></td>
                                <td>
                                    <table id="tcbg" class="table table-bordered table-striped">
                                        <tbody>
                                        <tr>
                                            <th align="left" style="background-color:#F9F9F9">(<font
                                                    color="red">*</font>)描述
                                            </th>
                                            <th align="left" style="background-color:#F9F9F9">(<font
                                                    color="red">*</font>)成本
                                            </th>
                                            <th align="left" style="background-color:#F9F9F9">(<font
                                                    color="red">*</font>)价格
                                            </th>
                                            <th align="left" style="background-color:#F9F9F9">(<font
                                                    color="red">*</font>)分成
                                            </th>
                                            <th align="left" style="background-color:#F9F9F9">(<font
                                                    color="red">*</font>)客服提成
                                            </th>
                                        </tr>


                                        </tbody>
                                    </table>


                                    <div style="margin-top:10px">
                                        <button class="btn btn-sm btn-primary"
                                                onclick="insertRowsc($VD(&#39;tcbg&#39;),23);return false;">
                                            <i class="icon-save"></i>
                                            增加
                                        </button>
                                        <!--<button class="btn btn-sm btn-danger" onclick="del_row($VD('tcbg'));return false;">
                                            <i class="icon-trash"></i>
                                            删除
                                      </button>-->
                                        (<font color="red">提示信息：</font>上述所有输入项均为必填项目，请务必填入相应值后保存！)
                                    </div>
                                </td>
                            </tr>
                            <tr>
                                <td align="right"><span class="red">*</span><strong>商品标签：</strong></td>
                                <td>


                                    <label>
                                        <input type="checkbox" class="ace" id="1" name="tags" value="1">
                                        <span class="lbl">
								             <span class="label label-danger">热销爆款</span>
								          </span>
                                    </label>
                                    &nbsp;&nbsp;
                                    <label>
                                        <input type="checkbox" class="ace" id="2" name="tags" value="2">
                                        <span class="lbl">
								             <span class="label label-pink">女粉推荐</span>
								          </span>
                                    </label>
                                    &nbsp;&nbsp;
                                    <label>
                                        <input type="checkbox" class="ace" id="3" name="tags" value="3">
                                        <span class="lbl">
								             <span class="label label-primary">男粉推荐</span>
										  </span>
                                    </label>
                                    &nbsp;&nbsp;
                                    <label>
                                        <input type="checkbox" class="ace" id="4" name="tags" value="4">
                                        <span class="lbl">
								             <span class="label label-success">人气新品</span>
								          </span>
                                    </label>
                                    &nbsp;&nbsp;
                                    <label>
                                        <input type="checkbox" class="ace" id="5" name="tags" value="5">
                                        <span class="lbl">
								             <span class="label label-info">男女通用</span>
								          </span>
                                    </label>


                                </td>
                            </tr>
                            <tr>
                                <td align="right"><span class="red">*</span><strong>微信文案：</strong></td>
                                <td>


                                    <input type="checkbox" class="ace" id="copy_1887427" name="gcopy" value="1887427">
                                    <span class="lbl">&nbsp;<a
                                            href="http://localhost:8081/cust/goods/add#">11</a></span><br>


                                </td>
                            </tr>

                            <tr>
                                <td align="right"><strong>站内文案：</strong></td>
                                <td>


                                </td>
                            </tr>

                            <tr>
                                <td align="right"><strong>空间文案：</strong></td>
                                <td>


                                    <input type="checkbox" class="ace" id="copy_39201701" name="zcopyId"
                                           value="39201701">
                                    <span class="lbl">&nbsp;<a
                                            href="http://localhost:8081/cust/goods/add#">12</a></span><br>


                                </td>
                            </tr>

                            <tr>
                                <td align="right"><strong>跳转说明：</strong></td>
                                <td>
                                    <textarea id="copy_desc" name="copyDesc"
                                              style="width:540px; height:80px;"></textarea>
                                </td>
                            </tr>

                            <tr>
                                <td align="right"><strong>跳转地址：</strong></td>
                                <td>
                                    <input type="text" id="forward_link" name="forwardLink" style="width:540px;"
                                           value="">
                                </td>
                            </tr>


                            <tr>
                                <td colspan="2" align="center">
                                    <button type="submit" class="btn btn-lxg btn-primary">保存</button>
                                    <span id="back" onclick="goToPage(&#39;/cust/goods/list&#39;);"
                                          class="btn btn-lxg btn-undo">
							             <i class="icon-undo bigger-120"></i>
							                返回 </span>
                                </td>
                            </tr>
                            </tbody>
                        </table>

                    </div>
                </form>

            </div><!-- /.page-content -->
        </div><!-- /.main-content -->

    </div><!-- /.main-container-inner -->

    <a href="http://localhost:8081/cust/goods/add#" id="btn-scroll-up" class="btn-scroll-up btn btn-sm btn-inverse">
        <i class="icon-double-angle-up icon-only bigger-110"></i>
    </a>
</div><!-- /.main-container -->

<!-- menu start-->


<!--[if !IE]> -->
<script src="static/jquery-2.0.3.min.js"></script>
<!-- <![endif]-->
<!--[if IE]>
<script src="/customer/assets/js/jquery-1.10.2.min.js"></script>
<![endif]-->
<!--[if !IE]> -->
<script type="text/javascript">
    window.jQuery || document.write("<script src='/customer/assets/js/jquery-2.0.3.min.js'>" + "<" + "script>");
</script>
<!-- <![endif]-->
<!--[if IE]>
<script type="text/javascript">
    window.jQuery || document.write("<script src='/customer/assets/js/jquery-1.10.2.min.js'>" + "<" + "script>");
</script>
<![endif]-->
<script type="text/javascript">
    if ("ontouchend" in document) document.write("<script src='/customer/assets/js/jquery.mobile.custom.min.js'>" + "<" + "script>");
</script>
<script src="static/bootstrap.min.js"></script>
<script src="static/typeahead-bs2.min.js"></script>
<!-- page specific plugin scripts -->
<!--[if lte IE 8]>
<script src="/customer/assets/js/excanvas.min.js"></script>
<![endif]-->

<script src="static/jquery-ui-1.10.3.custom.min.js"></script>
<script src="static/jquery.ui.touch-punch.min.js"></script>
<script src="static/bootbox.min.js"></script>
<script src="static/jquery.gritter.min.js"></script>

<!-- ace scripts -->
<script src="static/ace-elements.min.js"></script>
<script src="static/ace.min.js"></script>

<script type="text/javascript" src="static/WdatePicker.js"></script>
<script type="text/javascript" src="static/lhgdialog.min.js"></script>

<script type="text/javascript">
    jQuery(function ($) {
        $('table th input:checkbox').on('click', function () {
            var that = this;
            $(this).closest('table').find('tr > td:first-child input:checkbox')
                .each(function () {
                    if (!this.disabled) {
                        this.checked = that.checked;
                        $(this).closest('tr').toggleClass('selected');
                    }
                });
        });
    })
</script>

<script type="text/javascript">
    (function (config) {
        config['extendDrag'] = true; // 注意，此配置参数只能在这里使用全局配置，在调用窗口的传参数使用无效
        config['lock'] = true;
        config['fixed'] = true;
        config['okVal'] = '确定';
        config['cancelVal'] = '取消';
    })($.dialog.setting);

    // 如果只设置一个或少量全局配置也可这样：
    $.dialog.setting.extendDrag = true;

</script>
<!-- menu over-->

<script type="text/javascript">

    function submitData() {
        var gid = "";
        //var spc_id = getRadioValue('scopy_id');
        var spc_ids = getCheckBoxValue('scopy_id');
        var zon_ids = getCheckBoxValue('zcopy_id');
        var copy_ids = getCheckBoxValue("gcopy");
        if (isNull($("#good_name").val())) {
            $.dialog.alert("对不起！商品名称不能为空！");
            return false;
        }

        if (isNull($("#type_id").val())) {
            $.dialog.alert("对不起！请选择商户分类！");
            return false;
        }

        if (isNull($("#promote_desc").val())) {
            $.dialog.alert("对不起！推广说明不能为空！");
            return false;
        }

        if (isNull(copy_ids)) {
            $.dialog.alert("对不起！请选择微信文案！");
            return false;
        }

        /*if(isNull(spc_id)){
          $.dialog.alert("对不起！请选择站内文案！",null,false);
          return false;
        }*/

        if (isNull($("#order_no").val())) {
            $.dialog.alert("对不起！排序编号不能为空！");
            return false;
        }

        //处理sku
        var tab_rows = document.getElementById('tcbg').rows.length
        if (tab_rows == 1) {
            $.dialog.alert("对不起！请先设置商品套餐！");
            return false;
        }

        var ms = "";
        var cb = "";
        var jg = "";
        var fc = "";
        var kffc = "";
        for (var i = 0; i < tab_rows - 1; i++) {

            if (!isNull($("#sku" + (i + 1)).val())) {
                ms += $("#sku" + (i + 1)).val() + "|";
            }

            if (!isNull($("#cb" + (i + 1)).val())) {
                cb += $("#cb" + (i + 1)).val() + "|";
            }

            if (!isNull($("#jg" + (i + 1)).val())) {
                jg += $("#jg" + (i + 1)).val() + "|";
            }

            if (!isNull($("#fc" + (i + 1)).val())) {
                fc += $("#fc" + (i + 1)).val() + "|";
            }

            if (!isNull($("#kffc" + (i + 1)).val())) {
                kffc += $("#kffc" + (i + 1)).val() + "|";
            }

        }

        var sku_str = "";
        for (var i = 0; i < tab_rows - 1; i++) {

            if (!isNull($("#sku_id_" + (i + 1)).val())) {
                sku_str += $("#sku_id_" + (i + 1)).val() + "|";
            } else {
                sku_str += "newid|";
            }

            if (!isNull($("#sku" + (i + 1)).val())) {
                sku_str += $("#sku" + (i + 1)).val() + "|";
            }

            if (!isNull($("#cb" + (i + 1)).val())) {
                sku_str += $("#cb" + (i + 1)).val() + "|";
            }

            if (!isNull($("#jg" + (i + 1)).val())) {
                sku_str += $("#jg" + (i + 1)).val() + "|";
            }

            if (!isNull($("#fc" + (i + 1)).val())) {
                sku_str += $("#fc" + (i + 1)).val() + "|";
            }

            if (!isNull($("#kffc" + (i + 1)).val())) {
                sku_str += $("#kffc" + (i + 1)).val() + "|";
            }

            sku_str += "$";
        }

        $.dialog.confirm('你确定要提交数据吗？', function () {
            $.dialog.tips('数据保存中...', 600, 'loading.gif');
            var sform = document.copy_form;
            if (sform) {
                sform.action = "/good/saveGood";
                $('#sku_str').val(sku_str);
                $('#sku_title').val(ms);
                $('#sku_cost').val(cb);
                $('#sku_price').val(jg);
                $('#sku_pmoney').val(fc);
                $('#service_money').val(kffc);
                $('#copy_id').val(copy_ids);
                $('#spc_id').val(spc_ids);
                $('#zon_id').val(zon_ids);

                setTimeout(function () {
                    sform.submit();
                }, 500);
            }
        });

    }

    //验证商户是否在使用
    function checkGoodName(name, gid) {
        var param = "good_id=" + gid + "&good_name=" + name + "&now=" + new Date().getTime();
        return commonLoad("cust/goods/check", param, "post");
    }

    var tags = "";
    if (tags != "") {
        var com_obj = document.getElementsByName("tags");
        for (var j = 0; j < com_obj.length; j++) {
            if (tags.indexOf(com_obj[j].value) != -1) {
                com_obj[j].checked = true;
            } else {
                com_obj[j].checked = false;

            }
        }
    }

    var copys = "";
    if (copys != "") {
        var com_obj = document.getElementsByName("gcopy");
        for (var j = 0; j < com_obj.length; j++) {
            if (copys.indexOf(com_obj[j].value) != -1) {
                com_obj[j].checked = true;
            } else {
                com_obj[j].checked = false;
            }
        }
    }

    var spc_ids = "";
    if (spc_ids != "") {
        var com_obj = document.getElementsByName("scopy_id");
        for (var j = 0; j < com_obj.length; j++) {
            if (spc_ids.indexOf(com_obj[j].value) != -1) {
                com_obj[j].checked = true;
            } else {
                com_obj[j].checked = false;
            }
        }
    }

    var zon_ids = "";
    if (zon_ids != "") {
        var com_obj = document.getElementsByName("zcopy_id");
        for (var j = 0; j < com_obj.length; j++) {
            if (zon_ids.indexOf(com_obj[j].value) != -1) {
                com_obj[j].checked = true;
            } else {
                com_obj[j].checked = false;
            }
        }
    }

</script>


<div id="ldg_dragmask"
     style="display: none; position: fixed; left: 0px; top: 0px; width: 100%; height: 100%; cursor: move; opacity: 0; background: rgb(255, 255, 255); pointer-events: none;"></div>
<div>
    <div id="maskLevel" style="position:absolute;top:0;left:0;display:none;text-align:center;z-index:10000;"></div>
    <div id="ym-window" style="position:absolute;z-index:10001;display:none">
        <div class="ym-tl" id="ym-tl">
            <div class="ym-tr">
                <div class="ym-tc" style="cursor:move;">
                    <div class="ym-header-text"></div>
                    <div class="ym-header-tools"></div>
                </div>
            </div>
        </div>
        <div class="ym-ml" id="ym-ml">
            <div class="ym-mr">
                <div class="ym-mc">
                    <div class="ym-body"></div>
                </div>
            </div>
        </div>
        <div class="ym-ml" id="ym-btnl">
            <div class="ym-mr">
                <div class="ym-btn"></div>
            </div>
        </div>
        <div class="ym-bl" id="ym-bl">
            <div class="ym-br">
                <div class="ym-bc"></div>
            </div>
        </div>
    </div>
</div>
</body>
</html>